package com.xckj.cycling.dialog

import android.os.Bundle
import android.view.ViewGroup
import com.xckj.cycling.activity.MainActivity
import com.xckj.cycling.databinding.DialogTryRideLicenceBinding
import com.xckj.cycling.global.Constant
import com.xckj.cycling.utils.SpUtil

/**
 * 同意协议
 */
class TryRideLicenceShowDialog(
    context: MainActivity,
    val content: String,
    var callback: (Boolean) -> Unit
) :
    BaseDialog(context) {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val vb = DialogTryRideLicenceBinding.inflate(
            layoutInflater,
            window?.decorView as ViewGroup?, false
        )
        setContentView(vb.root)
        vb.content.loadData(content, "text/html", "UTF-8")
        vb.confirm.setOnClickListener {
            callback.invoke(true)
            SpUtil.put(context, Constant.TRY_RIDE_LICENCE, "1")
            dismiss()
        }
        vb.unConfirm.setOnClickListener {
            callback.invoke(false)
            dismiss()
        }
    }
}